<html>
	<head>
		<title>桥接模式</title>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<script>
			/*原始:  依赖性太强  */
			addEvent(element, 'click', getBeerById);
			function getBeerById(e) {
				var id = this.id;
				asyncRequest('GET', 'beer.uri?id=' + id, function(resp) {
					// Callback response.
					console.log('Requested Beer: ' + resp.responseText);
				});
			}

			/*桥接    分离出实体  */
			function getBeerById(id, callback) {
				// 通过ID发送请求，然后返回数据
				asyncRequest('GET', 'beer.uri?id=' + id, function(resp) {
					// callback response
					callback(resp.responseText);
				});
			}

			/*调用*/
			addEvent(element, 'click', getBeerByIdBridge);
			function getBeerByIdBridge(e) {
				getBeerById(this.id, function(beer) {
					console.log('Requested Beer: ' + beer);
				});
			}
		</script>
	</head>
	<body></body>
</html>